import { Component, OnInit } from '@angular/core';
import {LeaveRecord, OutRecord} from '../../domain/admin';
import {ServiceLogicService} from '../../service/service-logic.service';

@Component({
  selector: 'app-general-all-employee',
  templateUrl: './general-all-employee.component.html',
  styleUrls: ['./general-all-employee.component.css']
})
export class GeneralAllEmployeeComponent implements OnInit {
  leaveRecords: LeaveRecord[];
  outRecords: OutRecord[];
  cols1: any[];
  cols2: any[];
  constructor(private logicService: ServiceLogicService) { }

  ngOnInit() {
    this.logicService.getAllEmployeeLeaveRecord().then(res => {this.leaveRecords = res;
      for (let j = 0; j < this.leaveRecords.length; j++) {
        switch (this.leaveRecords[j].type) {
          case 0:
            this.leaveRecords[j].type_name = '事假';
            break;
          case 1:
            this.leaveRecords[j].type_name = '病假';
            break;
          case 2:
            this.leaveRecords[j].type_name = '婚假';
            break;
          case 3:
            this.leaveRecords[j].type_name = '产假';
            break;
          case 4:
            this.leaveRecords[j].type_name = '年假';
            break;
          default:
            break;
        }
      }
    });
    this.logicService.getAllEmployeeOutRecords().then(res => this.outRecords = res);

    this.cols1 = [
      {field: 'admin_id', header: 'admin_id'},
      {field: 'satrt_time', header: 'satrt_time'},
      {field: 'end_time', header: 'end_time'},
      {field: 'days', header: 'days'},
      {field: 'reason', header: 'reason'}
    ];
    this.cols2 = [
      {field: 'admin_id', header: 'admin_id'},
      {field: 'satrt_time', header: 'satrt_time'},
      {field: 'end_time', header: 'end_time'},
      {field: 'days', header: 'days'},
      {field: 'reason', header: 'reason'},
      {field: 'type_name', header: 'type_name'}
    ];
  }

}
